package cn.tedu.health.service.impl;

import cn.tedu.health.mapper.VisualizationsMapper;
import cn.tedu.health.pojo.entity.Visualizations;
import cn.tedu.health.service.IVisualizationsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class VisualizationsService implements IVisualizationsService {

    @Autowired
    private VisualizationsMapper visualizationsMapper;

    @Override
    public void createVisualization(Visualizations visualizations) {
        visualizationsMapper.insert(visualizations);
    }

    @Override
    public Visualizations getVisualization(Long userId, LocalDate date) {
        Map<String, Object> params = new HashMap<>();
        params.put("userId", userId);
        params.put("date", date);
        return visualizationsMapper.findByUserIdAndDate(params);
    }

    @Override
    public List<Visualizations> getVisualizationsByUserId(Long userId) {
        return visualizationsMapper.findByUserId(userId);
    }
}
